package com.mimc.controller.admin;

import com.jfinal.aop.Inject;
import com.jfinal.plugin.activerecord.Page;
import com.mimc.common.utils.StringUtils;
import com.mimc.core.model.SysOptLog;
import com.mimc.core.service.SysOptLogService;
import com.mimc.framework.domain.AjaxResult;
import io.jboot.db.model.Columns;
import io.jboot.web.controller.JbootController;
import io.jboot.web.controller.annotation.RequestMapping;

@RequestMapping("/admin/sys/opt/log")
public class SysOptLogController extends JbootController {

    @Inject
    private SysOptLogService sysOptLogService;
    public AjaxResult lists(){
        Integer page=getInt("page",1);
        Integer pageSize=getInt("pageSize",15);
        String userName=getPara("userName");
        Columns columns=Columns.create();
        if(StringUtils.isNotBlank(userName)){
            columns.eq("sys_admin.username",userName).or().eq("sys_admin.real_name",userName);
        }
        Page<SysOptLog> list=SysOptLog.DAO.alias("log").innerJoin("sys_admin").on("sys_admin.id=log.admin_id")
                .paginateByColumns(page,pageSize,columns,"log.create_time desc","log.*,sys_admin.username,sys_admin.real_name");
        return AjaxResult.success("成功",list);
    }
}
